using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Autofac;
using Cysharp.Threading.Tasks;
using ExceptionModule;
using UnityEngine;
using Debug = UnityEngine.Debug;
using Object = UnityEngine.Object;

class A : ILogHandler
{
    private readonly ILogHandler _defaultLogHandler;

    public A(ILogHandler defaultLogHandler)
    {
        _defaultLogHandler = defaultLogHandler;
    }

    public void LogFormat(LogType logType, Object context, string format, params object[] args)
    {
        _defaultLogHandler.LogFormat(logType, context, format, args);
    }

    public void LogException(Exception exception, Object context)
    {
        _defaultLogHandler.LogException(exception, context);
    }
}

public class NewBehaviourScript : MonoBehaviour
{
    
    // Start is called before the first frame update
    void Start()
    {
        // var builder = new ContainerBuilder();
        // builder.RegisterType<MyClass>();
        // var container = builder.Build();
        // container.Resolve<MyClass>();
        Debug.unityLogger.logHandler = new A(Debug.unityLogger.logHandler);
        Application.logMessageReceived += (string logString, string stackTrace, LogType type) =>
        {
            
        };
        ThrowExceptionAsync().Forget();

    }

    private static void ThrowException()
    {
        throw new Exception("manual throw exception");
    }
    
    private static UniTask ThrowExceptionAsync()
    {
        throw new Exception("manual throw exception");
    }
}

public interface IXxx
{
    
}

public class MyClass
{
    public MyClass(ICollection<IXxx> collection)
    {
        Debug.Log($"IXxx接口的数量：{collection.Count}");
    }
}
